<?php
    /* @var $this SiteController */

    $this->pageTitle=Yii::app()->name;
    /*
    $connection = Yii::app()->db;
    $sql = "SELECT DISTINCT ip, DATE_FORMAT(date, '%Y') AS 'date', page FROM hitcounter ORDER BY date;";
    $command = $connection->createCommand($sql);
    $rows = $command->queryAll();

    //Conto le pagine visitate nei vari anni
    $datas = array();
    $pagecount = 1;
    $ipcount = 1;
    $totalcountpage = 0;
    foreach ($rows as $key => $value){
        //echo $value['date']."<br>";
        if(($key+1)<  count($rows)){
            if($rows[$key+1]['date'] == $value['date']){
                $pagecount ++;
            }
            $datas['countpage'][$value['date']] = $pagecount;
        }
        $totalcountpage ++;
        $datas['date'][] = $value['date'];
    }
    $datas['totalcountpage'] = $totalcountpage;

    //Conto le visite totali
    foreach ($rows as $key => $value){
        //Creo l'array degli ip
        $ip[] = $value['ip'];
    }
    //Elimino i duplicati
    $ip = array_unique($ip);
    $datas['ipuniquecount'] = count($ip);//Conto gli ip che hanno visitato la pagina

    //Valori per il contatore delle pagine
    $valuesPageCount = '';
    foreach ($datas['countpage'] as $i => $value){
        $valuesPageCount .= '[\''.$i.'\','.$value.'], ';
    }
    
    //Visitatori
    $sql = "SELECT COUNT(*) AS 'count' FROM hitcounter;" ;
    $command = $connection->createCommand($sql);
    $rows = $command->queryAll();
    $datas['ipcount'] = $rows[0]['count'];

    //Valori per il contatore degli ip
    $sql = "SELECT COUNT(date) AS 'countdate', DATE_FORMAT(date, '%Y') AS 'date' FROM `hitcounter` GROUP BY DATE_FORMAT(date, '%Y');";
    $command = $connection->createCommand($sql);
    $ipcounter = $command->queryAll();
    foreach ($ipcounter as $key => $value){
        $datas['ipcounter'][$value['date']] = $value['countdate'];
    }
    
    //echo "<pre>";print_r($datas['ipcounter']);echo "</pre>";

    $valuesIpCounter = '';
    foreach ($datas['ipcounter'] as $key => $value){
        $valuesIpCounter .= '[\''.$key.'\', '.$value.'], ';
    }*/
    
    $showcase = new Showcase();
    $showcase->getAll();
?>

<!--<div id="showcase">
    <div class="hitcounter">
        <div class='page'>
            <div class='container'>
                <div class='name'>Pagine visitate</div>
                <div class='value'><?php //echo $datas['totalcountpage'] ?></div>
                <div class='link'><?php //echo CHtml::link('Grafico', array('graphics/hitcounterpage/datas/'.$valuesPageCount), array('target'=>'_blank')) ?></div>
            </div>
            
            <div class='container'>
                <div class='name'>Visitatori</div>
                <div class='value'><?php //echo $datas['ipcount'] ?></div>
                <div class='link'><?php //echo CHtml::link('Grafico', array('graphics/hitcounterip/datas/'.$valuesIpCounter), array('target'=>'_blank')) ?></div>
            </div>
            
            <div class='container'>
                <div class='name'>Visitatori unici</div>
                <div class='value'><?php //echo $datas['ipuniquecount'] ?></div>
                <!--<div class='link'><?php //echo CHtml::link('Grafico', array('graphics/hitcounterip/datas/'.$valuesIpCounter), array('target'=>'_blank')) ?></div>-->
            <!--</div>
        </div>
    </div>
</div>-->